This repository was archived by the owner on May 15, 2026. It is now read-only.
fix: use ID-based lookup for parallel tool finalization - #11007
Closed
daniel-lxs wants to merge 1 commit into
Closed
fix: use ID-based lookup for parallel tool finalization#11007daniel-lxs wants to merge 1 commit into
daniel-lxs wants to merge 1 commit into
Conversation
Replaces map-based index tracking with direct ID lookup when finalizing streaming tool calls. This prevents duplicate rendering of parallel tools by ensuring idempotent processing. Changes: - Use findIndex with partial===true check instead of streamingToolCallIndices - Skip already-finalized tools to eliminate race conditions - Works for both sequential and parallel tool calling modes The previous approach relied on streamingToolCallIndices map which could become stale when multiple code paths (finalization loop, sweep fix, pending updates) process the same tool, causing duplicate rendering.
Review complete. No issues found. The change is clean and addresses the duplicate rendering problem for parallel tools effectively. The ID-based lookup with Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
ghost
approved these changes
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces map-based index tracking with direct ID lookup when finalizing streaming tool calls. This prevents duplicate rendering of parallel tools by ensuring idempotent processing.
Problem
When parallel tools are called, they could sometimes be rendered twice because:
streamingToolCallIndicesmap-based lookup could reference tools that were already processedSolution
Use
findIndexwithpartial === truecheck instead ofstreamingToolCallIndices.get(event.id):partial === trueChanges
src/core/task/Task.ts: Replace map-based index lookup in finalization loop with ID-based lookupTesting
All 40 related tests pass:
Risk Assessment
Low risk - The change is targeted and defensive: